package com.fsai.cms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fsai.cms.domain.CmsCont;
import com.fsai.cms.mapper.CmsContMapper;
import com.fsai.cms.service.ICmsContService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 文章管理Service业务层处理
 * 
 * @author jaffe
 * @date 2021-03-12
 */
@Service
public class CmsContServiceImpl implements ICmsContService {
	@Autowired
	private CmsContMapper cmsContMapper;

	/**
	 * 查询文章管理
	 * 
	 * @param contId
	 *            文章管理ID
	 * @return 文章管理
	 */
	@Override
	public CmsCont selectCmsContById(Long contId) {
		return cmsContMapper.selectCmsContById(contId);
	}

	/**
	 * 查询文章管理列表
	 * 
	 * @param cmsCont
	 *            文章管理
	 * @return 文章管理
	 */
	@Override
	public List<CmsCont> selectCmsContList(CmsCont cmsCont) {
		return cmsContMapper.selectCmsContList(cmsCont);
	}

	@Override
	public List<CmsCont> selectTopNews(Long cateId, Integer pageCount) {
		return cmsContMapper.selectTopNews(cateId, pageCount);
	}

	@Override
	public PageInfo<CmsCont> queryPageData(CmsCont query, int pageSize, int pageNum) {
		if (pageNum > 0) {
			PageHelper.startPage(pageNum, pageSize);
		}
		PageHelper.orderBy("cont_pub_datetime desc");

		return new PageInfo<CmsCont>(cmsContMapper.selectCmsContSimpleList(query));
	}

	@Override
	public List<CmsCont> queryIndexCenterConts(String showCateIds, int count) {
		return cmsContMapper.queryIndexCenterConts(showCateIds, count);
	}

	@Override
	public List<CmsCont> searchConts(String qyparam, String orgCode) {
		return cmsContMapper.searchConts(qyparam, orgCode);
	}

}
